import request from '@/utils/request/request';
import requestForFile from '@/utils/request/requestForFile';

// 采购需求 - 列表查询
export function getDemandPage(params: any) {
  return request.get('/api/procurement/require/require-receive/page', {
    params,
  });
}

// 采购需求 - 修改
export function editDemand(data: any) {
  return request.put('/api/procurement/require/require-receive', data);
}

// 采购需求 - 单条删除
export function delDemandById(params: any) {
  return request.delete(`/api/procurement/require/require-receive`, {
    data: params,
  });
}

// 采购需求 - 批量删除
export function delDemandByIdList(data: any) {
  return request.delete(`/api/procurement/require/require-receive/list`, {
    data,
  });
}

// 采购需求 - 批量关闭
export function batchDemandClose(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doCloseList`,
    data
  );
}

// 采购需求 - 批量恢复关闭
export function batchDemandOpen(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doOpenList`,
    data
  );
}

// 采购需求 - 修改备注
export function batchDemandUpdateRemark(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doUpdateRemark`,
    data
  );
}

// 采购需求 - 批量修改备注
export function batchDemandUpdateRemarkList(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doUpdateRemarkList`,
    data
  );
}

// 采购需求 - 批量采购指定
export function batchDemandPurchase(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doPurchaseList`,
    data
  );
}

// 采购需求 - 确认
export function batchDemandConfirm(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doConfirm`,
    data
  );
}
// 采购需求 - 批量确认
export function batchDemandConfirmList(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doConfirmList`,
    data
  );
}

// 采购需求 - 全部确认
export function allDemandConfirmList(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doConfirmAll`,
    data
  );
}

// 采购需求 - 批量校验
export function batchDemandCheckList(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doCheckList`,
    data
  );
}
// 导出到Excel
export function batchDemandExport(params: any) {
  // 文件导出接口要用专门的requestForFile，且要求responseType为blob才行
  return requestForFile.get('/api/procurement/require/require-receive/export', {
    responseType: 'blob',
    params,
  });
}

// 采购需求 - 导入
export function batchDemandImport(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doImport`,
    data
  );
}

// 采购需求 - 导入关闭Excel
export function doCloseImport(data: any) {
  return request.post(
    `/api/procurement/require/require-receive/doCloseImport`,
    data
  );
}
